package com.cn.file.ha;

import com.cn.common.processor.INettyRequestProcessor;
import com.cn.msg.Message;
import io.netty.channel.ChannelHandlerContext;

import java.nio.charset.Charset;

public class HACopyData implements INettyRequestProcessor {

    public HAService haService;

    public HACopyData(HAService haService) {
        this.haService = haService;
    }

    @Override
    public Message process(Message message, ChannelHandlerContext ctx) {
        if (message != null) {
            String result = new String(message.getByteBodys(), Charset.forName("utf-8"));
            this.haService.setOffset(Long.valueOf(result));
            System.out.println("更新salve端位移完成，更新后的位移：" + this.haService.getOffset());
        }
        return null;
    }
}
